

from fastapi import APIRouter, Depends, HTTPException, status
from fastapi.security import OAuth2PasswordBearer, OAuth2PasswordRequestForm
from passlib.context import CryptContext

# import schemas
import jwt
# from database import get_db
from config import config


router = APIRouter(tags=["auth"])

oauth2_scheme = OAuth2PasswordBearer(tokenUrl="/login")


def get_user_token(token: str = Depends(oauth2_scheme)):
    payload = jwt.decode(token, config.JWT_SECRET_KEY,
                         algorithms=[config.JWT_ALGORITHM])
    return payload
